<style lang="less">
@import "./login.less";
</style>

<template>
  <div class="login">
    <center>
        <h1 style=" font-size: 40px;font-family: 方正小标宋简体;">临沂市基本养老服务</h1>
      <h1 style=" font-size:40px; font-family: 方正小标宋简体;">综合平台养老评估系统</h1>
     
      <br />
      <div class="login-con">
        <Card icon="log-in" title="欢迎登录" :bordered="false">
          <div class="form-con">
            <login-form @on-success-valid="handleSubmit"></login-form>
            <p class="login-tip"></p>
          </div>
        </Card>
      </div>
    </center>
    <img src="https://file.xiaoshanlinyi.com/ciji-admin/app_yanglao/ciji_code.png" class="img-app" />

    <a class="amark" rel="nofollow" href="http://www.beian.miit.gov.cn" target="_blank">鲁ICP备2021031369号-3</a>
  </div>
</template>

<script>
import LoginForm from "_c/login-form";
import { mapActions } from "vuex";
export default {
  components: {
    LoginForm
  },
  methods: {
    ...mapActions(["handleLogin", "getUserInfo","handleLoginById"]),
    handleSubmit({ userName, password }) {
      this.handleLogin({ userName, password }).then(res => {
        if (res.Type == 1) {
          if (res.Data.Type == 1) {
            this.$router.push({
              name: "area_saved"
            });
          } else {
            this.$router.push({
              name: this.$config.homeName
            });
          }
        } else {
          this.$Message.error("用户名或密码不正确");
        }
      });
    },
    LoginByGid(gid) {
      let vm = this;
      vm.$Message.loading({
        content: '自动登录中，请稍后...',
        duration: 3000
      });
      vm.handleLoginById({ id: gid }).then(res => {       
        if (res.Type == 1) {
          if (res.Data.Type == 1) {
            this.$router.push({
              name: "area_saved"
            });
          } else {
            this.$router.push({
              name: this.$config.homeName
            });
          }
        } else {
          this.$Message.error("用户名或密码不正确");
        }
      });
    }
  },
  mounted() {
    var gid = this.$route.query.gid
    if (gid) {
      this.LoginByGid(gid);
    }
  }
};
</script>

<style></style>
